unit FrameListView;

interface

uses
    Forms, Classes, Controls, ComCtrls, DataModule;
type
    TfrmeItemList = class(TFrame)
        ListView1: TListView;
    procedure ListView1DblClick(Sender: TObject);
    public
        constructor Create(AOwner: TComponent; node: TTreeNode); reintroduce;
        destructor Destroy();override;
    end;

implementation

{$R *.dfm}
uses SysUtils, Utils;

{ TfrmeItemList }

constructor TfrmeItemList.Create(AOwner: TComponent; node: TTreeNode);
var
    i: integer;
    n: TTreeNode;
begin
    inherited Create(AOwner);
    try
        if node <> nil then begin
            for i := 0 to node.Count - 1 do begin
                n := node.Item[i];
                with ListView1.Items.AddItem(nil) do begin
                    Caption := n.Text;
                    ImageIndex := n.ImageIndex;
                    Data := n;
                end;
            end;
        end;
    except
        on e: exception do WriteLog(e.Message);
    end;
end;

destructor TfrmeItemList.Destroy;
begin
  ListView1.Clear;
  inherited;
end;

procedure TfrmeItemList.ListView1DblClick(Sender: TObject);
var Item: TListItem;
    itm: TTreeNode;
begin
    if ListView1.Selected = nil then Exit;
    Item := ListView1.Selected;
    if Item.Data = nil then Exit;
    itm := TTreeNode(Item.Data);
    itm.TreeView.Selected := itm;
    Abort;
end;

end.

